define(['app'], function (app) {
    return {
        module: function ($scope, $http, eventBusService, httpService, params, configService) {

            httpService.post(app.urls.getUserInfo, $scope.form, function (data) {
                if ("0000" === data.code) {
                    $scope.username = data.data.displayName;
                    loadData();
                } else {
                    alert(data.msg);
                }
            });
            var loadData = function() {
                $scope.leftModule = app.include("modules/left?r="+Math.random());
                $scope.$apply();
            }

            //获取yml里的参数
            httpService.post(app.urls.parameter_select,{},function(data){
                if("0000" === data.code){
                    app.parameter = data.data;
                }else{
                    alert(data.msg);
                }
            });

            var IsPC = function() {
                var userAgentInfo = navigator.userAgent;
                var Agents = ["Android", "iPhone",
                    "SymbianOS", "Windows Phone",
                    "iPad", "iPod"];
                var flag = true;
                for (var v = 0; v < Agents.length; v++) {
                    if (userAgentInfo.indexOf(Agents[v]) > 0) {
                        flag = false;
                        break;
                    }
                }
                return flag;
            }
            $scope.warehouse = function (row) {
            	$scope.row_current = row;
                for (var i = 0; i < $scope.rows.length; i++) {
                    if ($scope.rows[i].id == row.id) {
                        $("." + row.id + "_menu").addClass("active");
                    } else {
                        $("." + $scope.rows[i].id + "_menu").removeClass("active");
                    }
                }
                if(IsPC()) {
                    var menu = {"url": "modules/content/welcome?currentMenu="+row.id};
                    if (row.path !== "/") {
                        menu = {"url": row.path};
                    }

                    eventBusService.publish("modules.content.load", menu);
                }
            }

        }
    }
});